package com.tfjybj.itoo.teach.provider.service.impl;

import com.dmsdbj.itoo.tool.base.service.impl.BaseServicePlusImpl;
import com.dmsdbj.itoo.tool.constantutil.YearSemester;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.teach.entity.TeacherCourseTeachClassEntity;
import com.tfjybj.itoo.teach.entity.TeacherTeachClassEntity;
import com.tfjybj.itoo.teach.model.SelectTeacherTeachClassModel;
import com.tfjybj.itoo.teach.model.TeacherTeachClassModel;
import com.tfjybj.itoo.teach.provider.dao.TeacherTeachClassDao;
import com.tfjybj.itoo.teach.provider.service.TeacherTeachClassService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * TeacherTeachClassService接口实现类
 * ${base}表
 *
 * @author 田成荣
 * @version 2.0.0
 * @since 2.0.0 2018-11-08 19:34:10
 */
@Service("teacherTeachClassService")
public class TeacherTeachClassServiceImpl extends BaseServicePlusImpl<TeacherTeachClassDao, TeacherTeachClassEntity> implements TeacherTeachClassService {
	
	//region 模板生成
    @Resource
    private TeacherTeachClassDao teacherTeachClassDao;
	
	 @Override
    public PageInfo<TeacherTeachClassEntity> queryByLikeTeachClassId(String teachClassId, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(teacherTeachClassDao.queryLikeTeachClassId(teachClassId));
    }
	//endregion

    /* **********************************以下为非模板生成的内容********************************* */


    /**
     * 根据上课班id查询学生信息
     * @param teachClassId
     * @return 学生姓名list
     * @author 郝雨烁
     * @since 0.0.1 2019年3月6日16:34:48
     */
    @Override
    public List<TeacherTeachClassModel> queryStudents(String teachClassId){
       return teacherTeachClassDao.queryStudents(teachClassId);
    }

    /**
     * 根据教师id查询上课班信息-郄子硕-2019-3-7 19:59:00
     * @param teacherId 教师Id
     * @return 上课班Model
     */
    @Override
    public List<TeacherTeachClassModel> queryTeachClass(String teacherId){
        return teacherTeachClassDao.queryTeachClass(teacherId);
    }

    /**
     * 根据teacherid查找TeacherTeachClass
     *
     * @param teacherId 教师id
     * @return 据教师id查找的结果
     * @author 郭满亮
     * @since 2.0.0 2019-1-27 14:46:36
     */
    @Override
    public List<SelectTeacherTeachClassModel> getByTeacherId(String teacherId, String templateId, String courseId) {
        //从工具类中获取学年学期数据

        String semester = YearSemester.getYearSemesterCode(0, 0).get(0);
        TeacherCourseTeachClassEntity teacherCourse=new TeacherCourseTeachClassEntity();
        teacherCourse.setSchoolYear(semester);
        teacherCourse.setTeacherId(teacherId);
        teacherCourse.setCourseId(courseId);
        // 教師所有班級
        List<SelectTeacherTeachClassModel> teacherTeachClassEntities = teacherTeachClassDao.getByTeacherId(teacherCourse);
        // 已发布班级 暂时注释
       /* List<SelectTeacherTeachClassModel> selectTeacherTeachClassModels = examineeDao.getTeacherClass(templateId);
        List<SelectTeacherTeachClassModel>  teacherTeachClassList = new ArrayList<>();
        for (SelectTeacherTeachClassModel teacherTeachClassEntity : teacherTeachClassEntities) {
            if (selectTeacherTeachClassModels.size() != 0 ) {
                for (SelectTeacherTeachClassModel selectTeacherTeachClassModel : selectTeacherTeachClassModels) {
                    if(!teacherTeachClassEntity.getTeachClassId().equals(selectTeacherTeachClassModel.getTeachClassId())) {
                        teacherTeachClassList.add(teacherTeachClassEntity);
                    }
                }
            } else {
                teacherTeachClassList = teacherTeachClassEntities ;
            }

        }
        HashSet h = new HashSet(teacherTeachClassList);
        teacherTeachClassList.clear();
        teacherTeachClassList.addAll(h);
        return teacherTeachClassList;*/
        return teacherTeachClassEntities;
    }
}
